var _excluded = ['items', 'renderItem'];
function _objectWithoutProperties(source, excluded) {
  if (source == null) return {};
  var target = _objectWithoutPropertiesLoose(source, excluded);
  var key, i;
  if (Object.getOwnPropertySymbols) {
    var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
    for (i = 0; i < sourceSymbolKeys.length; i++) {
      key = sourceSymbolKeys[i];
      if (excluded.indexOf(key) >= 0) continue;
      if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
      target[key] = source[key];
    }
  }
  return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {
  if (source == null) return {};
  var target = {};
  var sourceKeys = Object.keys(source);
  var key, i;
  for (i = 0; i < sourceKeys.length; i++) {
    key = sourceKeys[i];
    if (excluded.indexOf(key) >= 0) continue;
    target[key] = source[key];
  }
  return target;
}
import { Breadcrumb } from 'antd';
import 'antd/es/breadcrumb/style/index.js';
import React, { useMemo } from 'react';
import './index.less';

/**
 * 复杂的面包屑
 * 出于 antd@4, antd@5 兼容性考虑，不采用 antd@5.3.0 版本以上的 items 写法
 * 自定义 items 不支持 menu、path、href 配置
 * @param param0
 * @returns
 */
export default function ComplexBreadcrumbs(_ref) {
  var items = _ref.items,
    renderItem = _ref.renderItem,
    rest = _objectWithoutProperties(_ref, _excluded);
  var lastItem = useMemo(
    function () {
      return items[items.length - 1];
    },
    [items],
  );
  return /*#__PURE__*/ React.createElement(
    'div',
    {
      className: 'szzj-breadcrumbs szzj-breadcrumbs-complex',
    },
    /*#__PURE__*/ React.createElement(
      Breadcrumb,
      rest,
      items.map(function (item, index) {
        var _item$onClick, _item$onClick2;
        return /*#__PURE__*/ React.createElement(
          Breadcrumb.Item,
          {
            key: item.path,
            onClick:
              (_item$onClick =
                (_item$onClick2 = item.onClick) === null || _item$onClick2 === void 0
                  ? void 0
                  : _item$onClick2.call(item, item)) !== null && _item$onClick !== void 0
                ? _item$onClick
                : undefined,
          },
          /*#__PURE__*/ React.createElement(
            'span',
            {
              style: {
                cursor: item.onClick ? 'pointer' : 'inherit',
              },
            },
            renderItem ? renderItem(item, index) : item.title,
          ),
        );
      }),
    ),
    /*#__PURE__*/ React.createElement(
      'div',
      {
        className: 'szzj-breadcrumbs-title',
      },
      renderItem
        ? renderItem(lastItem)
        : lastItem === null || lastItem === void 0
        ? void 0
        : lastItem.title,
    ),
  );
}
